﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MasterPage_New.master" AutoEventWireup="true"
    CodeBehind="WarningSetupTimeForCompany_SC.aspx.cs" Inherits="HZ.Supervise.Web.Message.WarningSetupTimeForCompany_SC" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        $().ready(function() {
            $("form").validate();
        });
    
    </script>

    <script type="text/javascript" language="javascript">

        function SelectGoods() {
            var Sort = document.getElementById("ctl00_ContentPlaceHolder1_ddlDrugSort");
            var SortSource = document.getElementById("ctl00_ContentPlaceHolder1_ddlSortSource");
            showPopWin('选择药品', '../Common/SelectGoods.aspx?SortId=' + encodeURI(Sort.value) + '&SortSource=' + encodeURI(SortSource.value), 800, 400, null, true, true)
            //window.open('../Common/SelectGoods.aspx?SortId=' + encodeURI(Sort.value) + '&SortSource=' + encodeURI(SortSource.value) + '', 'selectReciever', 'width=800,height=500,resizable=0,scrollbars=1, status=0, toolbar=0, menubar=0');
        }
        function SelectCompany() {
//            var AreaName = document.getElementById("ctl00_ContentPlaceHolder1_txtArea");
//            var AreaId = document.getElementById("ctl00_ContentPlaceHolder1_hfdRecivedArea");
//            if (AreaName.value == null || AreaName.value == "") {
//                alert("请先选择地区");
//            }
            //            else {
            showPopWin('选择企业', '../Common/SelectCompany.aspx', 800, 400, null, true, true)
           // window.open('../Common/SelectCompany.aspx', 'selectReciever', 'width=800,height=500,resizable=0,scrollbars=1, status=0, toolbar=0, menubar=0');
//            }
        }

        //将选择的药品放入文本框
        function insertGoodsInfo(GoodsId, ProductName) {
            var varGoodsId = GoodsId;
            var varProductName = ProductName;
            var GoodsID = document.getElementById("ctl00_ContentPlaceHolder1_hdfRecivedGoods");
            var GoodsName = document.getElementById("ctl00_ContentPlaceHolder1_hdfRecivedGoodsName");
            var ProductName2 = document.getElementById("ctl00_ContentPlaceHolder1_txtDrug");
            ProductName2.value = varProductName;
            GoodsName.value = varProductName;
            GoodsID.value = varGoodsId;
            if ($("#ctl00_ContentPlaceHolder1_txtDrug").attr("value") != "") {
                $("#ctl00_ContentPlaceHolder1_ddlDrugSort").attr("disabled", "disabled");
                $("#ctl00_ContentPlaceHolder1_ddlSortSource").attr("disabled", "disabled");
            }
        }

        //将选择的企业放入文本框
        function insertCompanyInfo(HospitalId, HospitalName) {
            var varHospitalId = HospitalId;
            var varHospitalName = HospitalName;
            var hospitalID = document.getElementById("ctl00_ContentPlaceHolder1_hdfRecivedCompany");
            var hospitalName = document.getElementById("ctl00_ContentPlaceHolder1_hdfRecivedCompanyName");
            var hospitalNameShow = document.getElementById("ctl00_ContentPlaceHolder1_txtCompany");
            hospitalName.value = varHospitalName;
            hospitalNameShow.value = varHospitalName;
            hospitalID.value = varHospitalId;
           
        }


        //将选择的地区放入文本框
        function insertAreaInfo(AreaId, AreaName) {
            var varAreaId = AreaId;
            var varAreaName = AreaName;
            var RecievedareaID = document.getElementById("ctl00_ContentPlaceHolder1_hfdRecivedArea");
            var RecievedareaName = document.getElementById("ctl00_ContentPlaceHolder1_hfdRecivedAreaName");
            var RecievedareaNameShow = document.getElementById("ctl00_ContentPlaceHolder1_txtArea");
            RecievedareaName.value = varAreaName;
            RecievedareaNameShow.value = varAreaName;
            RecievedareaID.value = varAreaId;
            //显示选择企业的CheckBox
            if ($("#ctl00_ContentPlaceHolder1_txtArea").attr("value") != "") {
                $(".hospitalshoworhide").show();
                $("#ctl00_ContentPlaceHolder1_txtCompany").attr("value", "所有企业");
            }
            else {
                $(".hospitalshoworhide").hide();
            }
        }

        
    </script>

    <script type="text/javascript">
        $(document).ready(function() {
           
             $("#ctl00_ContentPlaceHolder1_txtCompany").attr("value", "所有企业");
             $("#ctl00_ContentPlaceHolder1_txtDrug").attr("value", "所有药品");
            $("#ctl00_ContentPlaceHolder1_ddlDrugSort").change(function() {
              
               
                    $("#ctl00_ContentPlaceHolder1_ddlSortSource").attr("value", "");
                    $("#ctl00_ContentPlaceHolder1_txtDrug").attr("value", "所有药品");
               
            });

            $("#ctl00_ContentPlaceHolder1_ddlSortSource").change(function() {
                var ddl = $("#ctl00_ContentPlaceHolder1_ddlSortSource").attr("value");
                if (ddl == "") {
                    $("#ctl00_ContentPlaceHolder1_txtDrug").attr("value", "所有药品");
                }
                else if ($("#ctl00_ContentPlaceHolder1_ddlSortSource").attr("value") == "0") {
                    $("#ctl00_ContentPlaceHolder1_txtDrug").attr("value", "所有基药");
                }
                else if ($("#ctl00_ContentPlaceHolder1_ddlSortSource").attr("value") == "1") {
                    $("#ctl00_ContentPlaceHolder1_txtDrug").attr("value", "所有非基药");
                }
            });
            $("#FirstClear").click(function() {
                $("#SelectArea").attr("disabled", "");
                $("#ctl00_ContentPlaceHolder1_txtCompany").attr("value", "所有企业");
                $("#ctl00_ContentPlaceHolder1_hdfRecivedCompany").attr("value", "");
                $("#ctl00_ContentPlaceHolder1_hdfRecivedCompanyName").attr("value", "");
            });
            $("#SecondClear").click(function() {
                $("#ctl00_ContentPlaceHolder1_ddlDrugSort").attr("disabled", "");
                $("#ctl00_ContentPlaceHolder1_ddlSortSource").attr("disabled", "");
                $("#ctl00_ContentPlaceHolder1_txtDrug").attr("value", "所有药品");
                $("#ctl00_ContentPlaceHolder1_hdfRecivedGoods").attr("value", "");
                $("#ctl00_ContentPlaceHolder1_hdfRecivedGoodsName").attr("value", "");
            });
        });
    </script>

    <div id="tabnav">

        <ul>
            <li><a href="WarningSetupTimeForHospital.aspx">医院规则</a> </li>
            <li><a href="WarningSetupTimeCompany.aspx">配送企业规则</a> </li>
            <li class="active"><a href="WarningSetupTimeForCompany_SC.aspx">生产企业规则</a> </li>
        </ul>
    </div>
   
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
         <tr>
            <td colspan="6">
                <span class="style4" style="text-align:left">
                <label style="color: Red">
                设置企业</label> </span>
            </td>
        </tr>
            <tr>            
          
                <th id="company"  align="right" class="style1">
                    企业
                </th>
                <td id="txtCompanys" align="left" class="style6" colspan="2">
                    <asp:TextBox ID="txtCompany" runat="server" Width="250px" Enabled="false"></asp:TextBox>
                    <asp:HiddenField ID="hdfRecivedCompany" runat="server" EnableViewState="true" />
                    <asp:HiddenField ID="hdfRecivedCompanyName" runat="server" EnableViewState="true" />
                    <input type="button" value="选择企业" class="btn" onclick="javascript:SelectCompany();" /></td>
                <td id="selectCompany" align="left" class="hospitalshoworhide">
                    &nbsp;</td>
                <th></th>
                <td>
                <input id="FirstClear" class="btn" name="button3" type="button" value="清空状态" /></td>
                <td></td>
            </tr>
             <tr>
            <td colspan="6">
                <hr />
            </td>
           </tr> 
            <tr>
            <td class="style12" colspan="6">
                <span class="style2" style="text-align:left">
                <label style="color: Red">
                设置药品</label> </span>
            </td>

        </tr>   
            <tr>
                <th id="sort"  align="right" class="style1">
                    药品类别
                </th>
                <td id="ddlSort" align="left"  class="style6" colspan="2">
                    <asp:DropDownList ID="ddlDrugSort" runat="server">
                    </asp:DropDownList>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<b>采购类型</b>                    
             
                    <asp:DropDownList ID="ddlSortSource" runat="server">
                        <asp:ListItem Value="">---请选择---</asp:ListItem>
                        <asp:ListItem Value="0">基药</asp:ListItem>
                        <asp:ListItem Value="1">非基药</asp:ListItem>
                    </asp:DropDownList>
                </td>
                 <th id="Th1" align="right"  class="style17">
              药品名称
              </th>
           <td id="Td1" align="left"  class="style19">
              <asp:TextBox ID="txtDrug" runat="server"  Width="250px" Enabled="false"></asp:TextBox>
               <asp:HiddenField ID="hdfRecivedGoods" runat="server" EnableViewState="true" />
               <asp:HiddenField ID="hdfRecivedGoodsName" runat="server" EnableViewState="true" />
               <input type="button" value="选择药品" class="btn"  onclick="javascript:SelectGoods();"/>
          </td>
         <td align="right" class="style18">
                <input id="SecondClear" class="btn" name="button2" type="button" value="清空状态" />
            </td>
            </tr>          
             <tr>
            <td colspan="6">
                <hr />
            </td>
        </tr>
             <tr>
            <td colspan="6">
                <span class="style16" style="text-align:left">
                <label style="color: Red">
                <nobr>
                设置触发条件</nobr>
                </label>
                </span>
            </td>
        </tr>
            <tr id="warningAmoutRange" class="sortshoworhide">
                
                <th align="right" class="style1">
                    预警级别
                </th>
                <td align="left" class="style6" colspan="2">
                    <asp:DropDownList ID="ddlLevel" runat="server">
                        <asp:ListItem Text="一级预警" Value="1"></asp:ListItem>
                        <asp:ListItem Text="二级预警" Value="2"></asp:ListItem>
                        <asp:ListItem Text="三级预警" Value="3"></asp:ListItem>
                    </asp:DropDownList>
                </td>
                <th align="right" class="style17">
                    预警类别
                </th>
                <td align="left" class="style19">
                    <asp:DropDownList ID="ddlType" runat="server">
                        <asp:ListItem Text="配送企业接收产品未入库" Value="10"></asp:ListItem>
                        <asp:ListItem Text="生产企业接收未响应" Value="11"></asp:ListItem>
                        <asp:ListItem Text="生产企业响应未发货" Value="12"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
            <th align="right"  class="style1" height="44">
                    违规时间
                </th>
                <td align="left"  class="style6">
                    <asp:TextBox ID="txtTimeOfRange" runat="server" Width="250px" CssClass="digits "
                        MaxLength="10"  OnKeyPress="if(((event.keyCode>=48)&&(event.keyCode <=57))) {event.returnValue=true;} else{event.returnValue=false;}"></asp:TextBox>
                    <asp:DropDownList ID="ddlTime" runat="server">
                        <asp:ListItem Text="日" Value="1"></asp:ListItem>
                        <asp:ListItem Text="周" Value="2"></asp:ListItem>
                        <asp:ListItem Text="月" Value="3"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td  align="center">
                    <asp:Button ID="btnConfirmMessage" runat="server" Text="制定完毕" CssClass="btn" OnClick="btnConfirmMessage_Click" />
                </td>
            </tr>
        </table>
 
    <asp:GridView runat="server" ID="gvwWarningStart" CssClass="mainlist" AutoGenerateColumns="False"
        EmptyDataText="暂无制定的规则！" OnRowDataBound="gvwWarningStart_RowDataBound" DataKeyNames="MessageDetailId">
        <Columns>
            <asp:TemplateField HeaderText="序号">
                <ItemTemplate>
                    <%# Container.DataItemIndex + 1 + AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1)%></ItemTemplate>
                <HeaderStyle Width="30px" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="预警对象">
                <ItemTemplate>
                    <asp:Label ID="lblCompanyName" ToolTip='<%#Eval("CompanyName") %>' runat="server"
                        Text='<%#Eval("CompanyName") %>' ReadOnly="true"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>          
            <asp:BoundField DataField="TypeName" HeaderText="预警类别" ReadOnly="true" />
            <asp:TemplateField HeaderText="药品名">
                <ItemTemplate>
                    <asp:Label ID="lblProductName" ToolTip='<%#Eval("ProductName") %>' runat="server"
                        Text='<%#Eval("ProductName") %>' ReadOnly="true"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="类别">
                <ItemTemplate>
                    <asp:Label ID="lblSortName" runat="server" Text='<%# Eval("SortName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="触发条件">
                <ItemTemplate>
                    <%#Eval("SqlDescription") %>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Level" HeaderText="预警级别" ControlStyle-Width="80px" 
                ReadOnly="true" >
<ControlStyle Width="80px"></ControlStyle>
            </asp:BoundField>
            <asp:TemplateField>
                <HeaderTemplate>
                    <input id="addTable_chkAll" name="chkAll" class="chkAll" type="checkbox" onclick="$('input[type=checkbox]').attr('checked', this.checked);" />
                </HeaderTemplate>
                <ItemTemplate>
                    <input type="checkbox" name="chk" class="item" id="chk" value='<%#Eval("MessageDetailId")%>' />
                </ItemTemplate>
                <HeaderStyle Width="25px" />
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <div class="page">
        <webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanged="AspNetPager1_PageChanged">
        </webdiyer:AspNetPager>
    </div>
    <div class="listctrl">
        <asp:Button ID="btnDelte" CssClass="btn" runat="server"  Text="删除" 
            OnClick="btnDelte_Click"
            onclientclick="if(getcheckcount('请至少选择一个要删除的预警')){ return confirm('确定要删除所选的预警吗？');} return false;" />
        <asp:Button ID="btnStart" CssClass="btn" runat="server" Text="启用" OnClick="btnStart_Click" onclientclick="if(getcheckcount('请至少选择一个要启用的预警')){ return confirm('确定要启用所选的预警吗？');} return false;"/>
    </div>

    <script type="text/javascript">
        function ValidateWarning() {
            var flag = true;
            //ddlTime预警范围
            var ddlTime = document.getElementById('ctl00_ContentPlaceHolder1_ddlTime');
            var txtTime = document.getElementById('ctl00_ContentPlaceHolder1_txtTimeOfRange');
            //ddlCountCompare、ddlCountCompare2预警数量范围比较方式
            var ddlCountCompare = document.getElementById('ctl00_ContentPlaceHolder1_ddlCountCompare');
            var ddlCountCompare2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlCountCompare2');
            var txtCount = document.getElementById('ctl00_ContentPlaceHolder1_txtCount');
            var txtCount2 = document.getElementById('ctl00_ContentPlaceHolder1_txtCount2');


            //下拉框ddlAmountCompare、ddlAmountCompare2预警金额范围比较方式（value值： 1大于等于 0小于等于）
            var ddlAmountCompare = document.getElementById('ctl00_ContentPlaceHolder1_ddlAmountCompare');
            var ddlAmountCompare2 = document.getElementById('ctl00_ContentPlaceHolder1_ddlAmountCompare2');
            var txtAmount = document.getElementById('ctl00_ContentPlaceHolder1_txtAmount');
            var txtAmount2 = document.getElementById('ctl00_ContentPlaceHolder1_txtAmount2');
            //下拉框ddlTime的value 1是周 2月  3季度 4年
            if (ddlTime.value == '1') {
                if (txtTime.value > 5) {
                    alert("监控周不可以超过5个自然周");
                    flag = false;
                }
            }
            if (ddlTime.value == '2') {
                if (txtTime.value > 5) {
                    alert("监控周不可以超过5个自然月");
                    flag = false;
                }
            }
            if (ddlTime.value == '3') {
                if (txtTime.value > 5) {
                    alert("监控周不可以超过5个自然季度");
                    flag = false;
                }
            }
            //对预警数量判断
            if (ddlCountCompare.value == "1") {
                //数量大于第一个数字，且大于第二个数字
                if (ddlCountCompare2.value == "1") {
                    alert('预警数量不可以同时大于等于');
                    flag = false;
                }
            }
            else {
                //数量小于第一个数字，且小于第二个数字
                if (ddlCountCompare2.value == "0") {
                    alert('预警数量不可以同时小于等于');
                    flag = false;
                }
            }
            //对预警金额判断
            if (ddlAmountCompare.value == "1") {
                //数量大于第一个数字，且大于第二个数字
                if (ddlAmountCompare2.value == "1") {
                    alert('预警金额不可以同时大于等于');
                }
            }
            else {
                //数量小于第一个数字，且小于第二个数字
                if (ddlAmountCompare2.value == "0") {
                    alert('预警金额不可以同时小于等于');
                }
            }
            return flag;
        }
    </script>

</asp:Content>
<asp:Content ID="Content3" runat="server" contentplaceholderid="head">

    <style type="text/css">
        .style1
        {
            width: 78px;
        }
        .style2
        {
            width: 14%;
        }
        .style3
        {
            width: 14%;
        }
        .style4
        {
            width: 18%;
        }
        .style5
        {
            width: 35%;
        }
        .style6
        {
            border-style: none;
            border-color: inherit;
            border-width: 0;
            width: 37%;
            font: 12px ;
            color: #000000;
            text-align: left;
            margin-top: 0px;
        }

        .style17
        {
            width: 64px;
        }
        .style18
        {
            width: 40px;
        }
        .style19
        {
            width: 548px;
        }
    </style>

</asp:Content>
